package com.chainyoung.component_tmtrade.ui.mvp.model;

import com.chainyoung.common.di.scope.FragmentScope;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmtrade.api.TradeService;
import com.chainyoung.component_tmtrade.bean.MyBanlance;
import com.chainyoung.component_tmtrade.bean.TotalAsset;
import com.chainyoung.component_tmtrade.ui.mvp.contract.TradeCurrencyBuyContract;

import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;


@FragmentScope
public class TradeCurrencyBuyModel extends TradeCurrencyListModel implements TradeCurrencyBuyContract.Model {

    @Inject
    TradeCurrencyBuyModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);

    }


    @Override
    public Flowable<Object> addExchange(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .addExchange(map)
                .compose(RxUtils.<Object>handleResult());
    }


    @Override
    public Flowable<MyBanlance> getMyBanlance(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .getMyBalance(map)
                .compose(RxUtils.<MyBanlance>handleResult());
    }

    @Override
    public Flowable<Object> cancelTrade(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .cancelExchange(map)
                .compose(RxUtils.handleResult());
    }



//    @Override
//    public Flowable<TotalAsset> getTotalAsset(TreeMap<String, Object> map) {
//        return mRepositoryManager.obtainRetrofitService(TradeService.class)
//                .getTotalAsset(map)
//                .compose(RxUtils.<TotalAsset>handleResult());
//    }


}